//
//  MainViewController.swift
//  Sinaweibo
//
//  Created by 谌桃 on 15/11/27.
//  Copyright © 2015年 ryan.chen. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    private func addChildViewControllers() {
        
        addChildVC("首页", imageName:"tabbar_home" , Vc: HomeTableViewController())
        addChildVC("消息", imageName: "tabbar_message_center", Vc: MessageTableViewController())
        addChildVC("发现", imageName: "tabbar_discover", Vc: DiscoverTableViewController())
        addChildVC("我的", imageName: "tabbar_profile", Vc: ProfileTableViewController())
    }

    private func addChildVC(title:String , imageName:String , Vc:UIViewController){
        
        //创建导航控制器
        let nav = UINavigationController(rootViewController: Vc)
        
        Vc.title = title
        
        Vc.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
        
    }
}
